<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2018/3/14
  Time: 14:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  String jsessionid = session.getId();
%>

<style>
  table th,table td,table input{
    text-align: center;
    vertical-align: middle;
  }
  #photoImg{
    position: absolute;
    right: 0;
  }
  #photoImg img{
    border: 1px solid #CCC;
    max-width: 250px;
    max-height: 370px;
  }
</style>

<div class="panel" style="margin-bottom: 0">

  <div class="panel-heading">
    <ul class="nav nav-tabs">
      <li class="active"><a href="#s1" id="tab1" data-toggle="tab">基础信息</a></li>
      <li class=""><a href="#s2" id="tab2" data-toggle="tab">学习经历</a></li>
      <li class=""><a href="#s3" id="tab3" data-toggle="tab">工作经历</a></li>
      <li class=""><a href="#s4" id="tab4" data-toggle="tab">奖惩情况</a></li>
      <li class=""><a href="#s5" id="tab5" data-toggle="tab">家庭信息</a></li>
    </ul>
  </div>


  <div class="panel-heading header">
    <h3 class="panel-title" id="title">人员信息表</h3>
  </div>

  <!-- BASIC FORM ELEMENTS -->
  <!--===================================================-->
  <form id="form_person_input" class="form-horizontal" style="position: relative">
    <div class="tab-content">
      <!-- 基本信息 -->
      <div class="tab-pane fade in active" id="s1">

        <input type="hidden" name="keyId" id="keyId" value="${person.id}"/>
        <input type="hidden" name="curDutyId" id="curDutyId" value=""/>
        <input type="hidden" name="isDirector" id="isDirector" value="${isDirector}"/>
        <input type="hidden" name="studyJSON" id="studyJSON" value=""/>
        <input type="hidden" name="workJSON" id="workJSON" value=""/>
        <input type="hidden" name="familyJSON" id="familyJSON" value=""/>

        <div class="form-group">
          <label class="col-md-2 control-label">姓名<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input type="text" name="name" id="name" class="form-control" placeholder="请输入姓名" value="${person.name}">
          </div>

          <label class="col-md-2 control-label">性别<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input type="text" name="gender" id="gender" class="form-control" value="${person.gender}">
          </div>

          <c:if test="${person.photo!=null}">
            <div class="col-md-3" id="photoImg">
              <img class="img-responsive" alt="Responsive image" title="头像" src="../common/file/download?${person.photo.url}" />
            </div>
          </c:if>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">出生日期<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择出生日期" id="birthday" name="birthday" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy年MM月" value="${person.birthday}" />">
          </div>

          <label class="col-md-2 control-label">民族<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input type="text" name="nationId" id="nationId" class="form-control" value="${person.nation.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">籍贯<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入籍贯" id="origin" name="origin" class="form-control" type="text" value="${person.origin}">
          </div>

          <label class="col-md-2 control-label">出生地<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入出生地" id="birthPlace" name="birthPlace" class="form-control" type="text" value="${person.birthPlace}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">入党时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择入党时间" id="joinPartyDate" name="joinPartyDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy年MM月" value="${person.joinPartyDate}" />">
          </div>

          <label class="col-md-2 control-label">参加工作时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择参加工作时间" id="joinWorkDate" name="joinWorkDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy年MM月" value="${person.joinWorkDate}" />">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">健康状况<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入健康状况" id="health" name="health" class="form-control" type="text" value="${person.health}">
          </div>

          <label class="col-md-2 control-label">熟悉专业专长<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入熟悉专业专长" id="specialty" name="specialty" class="form-control" type="text" value="${person.specialty}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">工作性质<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" name="workNatureId" id="workNatureId" class="form-control" value="${person.workNature.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">人员性质<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" name="personNature" id="personNature" class="form-control" value="${person.personNature.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">最高学历<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" name="highEdu" id="highEdu" class="form-control" value="${person.highEdu.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">全日制教育</label>
          <div class="col-md-2">
            <input type="text" name="allDayEdu" id="allDayEdu" class="form-control" value="${person.allDayEdu.name}">
          </div>

          <label class="col-md-2 control-label">毕业院校系及专业</label>
          <div class="col-md-2">
            <input placeholder="请输入毕业院校系及专业" id="allDaySchool" name="allDaySchool" class="form-control" type="text" value="${person.allDaySchool}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">在职教育</label>
          <div class="col-md-2">
            <input type="text" name="jobEdu" id="jobEdu" class="form-control" value="${person.jobEdu.name}">
          </div>

          <label class="col-md-2 control-label">毕业院校系及专业</label>
          <div class="col-md-2">
            <input placeholder="请输入毕业院校系及专业" id="jobSchool" name="jobSchool" class="form-control" type="text" value="${person.jobSchool}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">现任职务<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入现任职务" id="nowPost" name="nowPost" class="form-control" type="text" value="${person.nowPost}">
          </div>

          <label class="col-md-2 control-label">任现职时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择任现职时间" id="nowPostDate" name="nowPostDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy年MM月" value="${person.nowPostDate}" />">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">所在区<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input readonly placeholder="请输入所在区" id="area" name="area" class="form-control" type="text" value="${person==null?'杨浦区':person.area}">
          </div>

          <label class="col-md-2 control-label">所在街道<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input type="text" name="street" id="street" class="form-control" value="${person.street.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">居民区<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" name="resident" id="resident" class="form-control" value="${person.resident.name}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">一肩挑书记情况<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" name="shoulder" id="shoulder" class="form-control" value="${person.shoulder==1?"一肩挑":"否"}">
          </div>
        </div>

        <div class="form-group" <c:if test='${person == null || person.shoulder==0}'>style="display:none"</c:if>>
          <label class="col-md-2 control-label">一肩挑书记详情<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <div class="checkbox">
              <input disabled type="checkbox" id="shoulderDet1" class="magic-checkbox" name="shoulderDet" value="已一肩挑" <c:if test="${fn:indexOf(person.shoulderDet,'已一肩挑')>=0}">checked</c:if> >
              <label for="shoulderDet1">已一肩挑</label>

              <input disabled type="checkbox" id="shoulderDet2" class="magic-checkbox" name="shoulderDet" value="拟一肩挑连任" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑连任')>=0}">checked</c:if> >
              <label for="shoulderDet2">拟一肩挑连任</label>

              <input disabled type="checkbox" id="shoulderDet3" class="magic-checkbox" name="shoulderDet" value="拟一肩挑备选" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑备选')>=0}">checked</c:if> >
              <label for="shoulderDet3">拟一肩挑备选</label>
            </div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">照片<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input name="uploadify" id="photoName" placeholder="" type="file" style="display: none" >
            <input name="photoId" id="photoId" style="display: none" value="${person.photo.id}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">填写人</label>
          <div class="col-md-2">
            <input disabled type="text" class="form-control" value="${person.creater.name}">
          </div>
          <label class="col-md-2 control-label">填写日期</label>
          <div class="col-md-2">
            <input disabled type="text" class="form-control" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${person.createTime}" />">
          </div>
        </div>

        <c:if test='${(person.processState=="Running" || person.processState=="Backed") && stepNo !=1 && stepNo !=0}'>
          <div class="form-group" id="comment">
            <label class="col-md-2 control-label">审批意见</label>
            <div class="col-md-6">
              <textarea name="editor" id="editor" style="height:200px;"></textarea>
            </div>
          </div>
        </c:if>

      </div>

      <!-- 学习经历 -->
      <div class="tab-pane fade" id="s2">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <table class="table table-bordered" id="studyTable">
              <thead>
              <tr>
                <th colspan="4">学习经历</th>
              </tr>
              <tr>
                <th width="25%">开始时间</th>
                <th width="25%">结束时间</th>
                <th width="25%">学校</th>
                <th width="25%">所获学位</th>
              </tr>
              </thead>
              <tbody id="studyTbody">
              <c:forEach items="${person.studyList}" var="item" varStatus="index">
                <tr>
                  <td><input type="text" class="form-control date" name="startDate" value="<fmt:formatDate pattern="yyyy年MM月" value="${item.startDate}" />" ></td>
                  <td><input type="text" class="form-control date" name="endDate" value="<fmt:formatDate pattern="yyyy年MM月" value="${item.endDate}" />" ></td>
                  <td><input type="text" class="form-control" name="school" value="${item.school}" ></td>
                  <td><input type="text" class="form-control" name="academicDegree" value="${item.academicDegree}" ></td>
                </tr>
              </c:forEach>
              </tbody>
            </table>
          </div>
        </div>
      </div>

      <!-- 工作经历 -->
      <div class="tab-pane fade" id="s3">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <table class="table table-bordered" id="workTable">
              <thead>
              <tr>
                <th colspan="5">工作经历</th>
              </tr>
              <tr>
                <th width="20%">开始时间</th>
                <th width="20%">结束时间</th>
                <th width="20%">工作单位及部门</th>
                <th width="20%">职务（职级）</th>
                <th width="20%">证明人</th>
              </tr>
              </thead>
              <tbody id="workTbody">
              <c:forEach items="${person.workList}" var="item" varStatus="index">
                <tr>
                  <td><input type="text" class="form-control date" name="workStartDate" value="<fmt:formatDate pattern="yyyy年MM月" value="${item.workStartDate}" />" ></td>
                  <td><input type="text" class="form-control date" name="workEndDate" value="<fmt:formatDate pattern="yyyy年MM月" value="${item.workEndDate}" />" ></td>
                  <td><input type="text" class="form-control" name="workDept" value="${item.workDept}" ></td>
                  <td><input type="text" class="form-control" name="workPost" value="${item.workPost}" ></td>
                  <td><input type="text" class="form-control" name="proveUser" value="${item.proveUser}" ></td>
                </tr>
              </c:forEach>
              </tbody>
            </table>
          </div>
        </div>
      </div>

      <!-- 奖惩情况 -->
      <div class="tab-pane fade" id="s4">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <textarea class="form-control" name="reward" rows="5" >${person.reward}</textarea>
          </div>
        </div>
      </div>

      <!-- 家庭信息 -->
      <div class="tab-pane fade" id="s5">
        <div class="form-group">
          <div class="col-md-10 col-md-offset-1">
            <table class="table table-bordered" id="familyTable">
              <thead>
              <tr>
                <th colspan="7">家庭信息</th>
              </tr>
              </thead>
              <tbody id="familyTbody">
              <tr>
                <td width="5%" style="vertical-align: middle" rowspan="${fn:length(person.familyList)+1}">家庭主要成员及重要社会关系</td>
                <th width="15%">称谓</th>
                <th width="15%">姓名</th>
                <th width="15%">出生年月</th>
                <th width="15%">政治面貌</th>
                <th width="15%">学历学位</th>
                <th width="19%">工作单位及职务</th>
              </tr>

              <c:forEach items="${person.familyList}" var="item" varStatus="index">
                <tr>
                  <td><input type="text" class="form-control" name="nickName" value="${item.nickName}" ></td>
                  <td><input type="text" class="form-control" name="familyName" value="${item.familyName}" ></td>
                  <td><input type="text" class="form-control date" name="familyBirthday" value="<fmt:formatDate pattern="yyyy年MM月" value="${item.familyBirthday}" />" ></td>
                  <td><input type="text" class="form-control" name="politicalStatus" value="${item.politicalStatus}" ></td>
                  <td><input type="text" class="form-control" name="familyEdu" value="${item.familyEdu}" ></td>
                  <td><input type="text" class="form-control" name="familyJob" value="${item.familyJob}" ></td>
                </tr>
              </c:forEach>

              <tr>
                <td rowspan="2" style="vertical-align: middle">家庭地址</td>
                <td colspan="3" rowspan="2"><textarea style="width: 100%;height: 100%" class="form-control" name="familyAddress">${person.familyAddress}</textarea></td>
                <td>联系电话</td>
                <td colspan="2"><input type="number" class="form-control" name="phone" value="${person.phone}" ></td>
              </tr>
              <tr>
                <td>邮编</td>
                <td colspan="2"><input type="number" class="form-control" name="zipCode" value="${person.zipCode}" ></td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>

    </div>
  </form>
</div>
<!--===================================================-->
<!-- END BASIC FORM ELEMENTS -->

<div class="panel-footer">
  <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
    <i class="fa fa-lg fa-mail-reply"></i> 返回
  </a>
  <a class="btn btn-default" key="ajax_edit" href="javascript:void(0);" ${isEdit}>
    <i class="fa fa-lg fa-edit"></i> 编辑
  </a>
</div>

</div>

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";
  var stepNo = "${stepNo}";

  $(function(){

    $("#form_person_input input,#form_person_input textarea").attr("readonly", true);

    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_person_input #keyId").val()+"&type=flow",$('#showFlow'));
    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_person_input #keyId").val()+"&type=next",$('#showNext'));
    __ajax_post("<%=path%>/com/running/operateType",{keyId: $("#form_person_input #keyId").val()},function(pdata){
      var showDuty = false;
      var area = $("div.panel-footer");
      var edit = null;
      if (stepNo == 1){
        return false;
      }
      $(pdata.datarows).each(function(i,v){
        var str = '<a id="left_foot_btn_'+ v.action+'" class="btn btn-warning" href="javascript:void(0);"><i class="fa fa-upload">'+ v.name+'</i></a>&nbsp;';
        $(area).append(str);
        if(v.action == "approve" || v.action=="sendback"  || v.action=="deny"){
          showDuty = true;
        }
      });
      if(showDuty == true){
        var pdata = {
          keyId: $("#form_person_input #keyId").val(),
          entityName: "com.fz.us.oa.core.entity.com.${isDirector==1?'Director':'Person'}"
        };
        multiDuty(pdata);
      }else{
        $('#comment').hide();
      }
      if($(':visible#editor').length == 1){
        edit  = new UE.ui.Editor();
        edit.render('editor');
      }
      //通过
      $("#left_foot_btn_approve").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var stepNo = "${stepNo}";
        if(stepNo == "3"){
          var rs =  $("#form_person_input").valid();
          if(!rs){
            return false;
          }
        }
        __form_save("form_person_input","<%=path%>/com/person/approve?comment="+comment,function(){
          $("#apply-re-common").trigger("click");
        })
      });
      //退回
      $("#left_foot_btn_sendback").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/person/back?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("input#keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common").trigger("click");
        });
      });
      //否决
      $("#left_foot_btn_deny").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/person/deny?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("input#keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common").trigger("click");
        });
      });
    });

    //流程信息展开
    $('#flow,#next').click(function(){
      if($(this).hasClass("right")){
        $(this).removeClass("right").addClass("down");
        $(this).parent(".f_title").next("div.f_content").show();
      }else{
        $(this).removeClass("down").addClass("right");
        $(this).parent(".f_title").next("div.f_content").hide();
      }
    });
  });

  // 附件上传
  readLoad({
    objId:"photoName",
    entityName:"photoIds",
    sourceId:"photoId",
    jsessionid:"<%=jsessionid%>"
  });

  //返回视图
  $("#apply-re-common").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });

  //编辑
  $("a[key=ajax_edit]").click(function(){
    loadURL("<%=path%>/com/person/input?keyId="+$("input#keyId").val()+"&isDirector="+$("#isDirector").val()+"&draft="+draft+"&todo="+todo+"&remind="+remind+"&record="+record+"&index="+index,$('#page-content'));
  });


</script>